home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / procssng / ccs / ccs-11tl.lha / lbl / x11 / jpeg / lib / hread_jheader.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-22  |  1.4 KB  |  60 lines

  1. /*    Hips_READ_JpegHEADER . C
  2. %
  3. %
  4. */
  5.  
  6. #include "jinclude.h"
  7.  
  8. U_IMAGE   uimg;
  9. struct Decompress_info_struct dinfo;
  10. struct Decompress_methods_struct dc_methods;
  11. struct External_methods_struct e_methods;
  12.  
  13. METHODDEF void
  14. d_ui_method_selection(decompress_info_ptr cinfo)
  15. {
  16.     /* if grayscale or CMYK input, force similar output; */
  17.     /* else leave the output colorspace as set by options. */
  18.     if (cinfo->jpeg_color_space == CS_GRAYSCALE)
  19.     cinfo->out_color_space = CS_GRAYSCALE;
  20.     else if (cinfo->jpeg_color_space == CS_CMYK)
  21.     cinfo->out_color_space = CS_CMYK;
  22.  
  23. /*
  24.     jselwdefault(cinfo);
  25. */
  26. }
  27.  
  28. /* this routine reads the main JFIF header and the scan header for the
  29.    first frame */
  30. hread_jmain_header(FILE * fp)
  31. {
  32.  
  33.     dinfo.img = &uimg;
  34.     dinfo.methods = &dc_methods;
  35.     dinfo.emethods = &e_methods;
  36.     jselerror(&e_methods);    /* error/trace message routines */
  37.     jselmemmgr(&e_methods);    /* memory allocation routines */
  38.     dc_methods.d_ui_method_selection = d_ui_method_selection;
  39. /*
  40.     emethods = &e_methods;
  41. */
  42.     j_d_defaults(&dinfo, TRUE);
  43.  
  44.     /* main set up     */
  45.     jpeg_uimg_init(fp, HIPS, 0, True);
  46.     dinfo.input_file = fp;
  47.     dinfo.output_file = stdout;
  48.     jselrjfif(&dinfo);
  49.  
  50.     if ((*dinfo.methods->read_file_header) (&dinfo) < 0
  51.         || ! ((*dinfo.methods->read_scan_header) (&dinfo)))
  52.     return EOF;        /* error     */
  53.     return 0;
  54. }
  55.  
  56. hread_jscan_header(FILE * fp)
  57. {
  58.     return !(*dinfo.methods->read_scan_header) (&dinfo);
  59. }
  60.